def get_modifying_args(w, h, target_w, target_h, aspect_ratio):

    if target_w and target_h:
        # 这句忘了
        aspect_ratio = target_w / target_h
    elif target_w:
        target_h = target_w / aspect_ratio
    elif target_h:
        target_w = target_h * aspect_ratio
    elif aspect_ratio:
        target_w = w
        target_h = h
    else:
        raise Exception('参数错误')
    
    resize_w_int = int(round(target_w, 0))
    resize_h_int = int(round(target_h, 0))
    
    if (w==resize_w_int and h==resize_h_int) or (w==target_w and h==target_h):
        # 须裁剪的尺寸和原始尺寸相同
        return

    # if true, 竖切. 否则横切
    if w/h > aspect_ratio:
        resize_w = w*(target_h/h)
        h_spacing = (resize_w - target_w) / 2

        # resize不接受float, 因此要将潜在的float改为int
        resize_w_int = int(round(resize_w, 0))
        
        return h_spacing, 0, h_spacing + target_w, resize_h_int, resize_w_int, resize_h_int

    else:
        resize_h = h * (target_w / w)
        v_spacing = (resize_h - target_h) / 2

        # resize不接受float, 因此要将潜在的float改为int
        
        resize_h_int = int(round(resize_h, 0))
        return 0, v_spacing, resize_w_int, v_spacing+target_h, resize_w_int, resize_h_int